
{extend name='public/window' /}

{block name="content"}

<div class="layui-fluid">
    <div class="layui-card">
        <!-- <div class="layui-card-header"></div>-->

        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="form">

                <div class="layui-form-item">
                    <label class="layui-form-label">上级菜单：</label>
                    <div class="layui-input-block">
                        <select name="pid" lay-search="">
                            <option value="0" {eq name="$pid" value="0"} selected {/eq}>顶级菜单</option>
                            {volist name="tree" id="t"}
                            <option value="{$t.id}" {eq name="$pid" value="$t.id"} selected {/eq}>{$t.title_show}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <input type="hidden" name="font_family" value="fa">

                {if isset($info.id)}
                <input type="hidden" name="id" value="{$info.id}">
                {/if}

                <input type="hidden" name="__token__" id="token" value="{:token()}"/>

                <div class="layui-form-item">
                    <label class="layui-form-label label-required-next">菜单名称：</label>
                    <div class="layui-input-block input-custom-width" style="">
                        <input type="text" name="title" value="" placeholder="请输入菜单或按钮名称" lay-verify="required" lay-vertype="tips" lay-reqtext="请输入菜单名称" autocomplete="off" class="layui-input ">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label  class="layui-form-label">菜单图标：</label>
                    <div class="layui-input-block">
                        <input type="text" id="iconPicker" name="icon" value="" lay-filter="iconPicker" class="hide">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label label-required-next">是否菜单：</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="radio" name="type" value="1" title="菜单" lay-filter=""  checked>
                        <input type="radio" name="type" value="2" title="按钮" lay-filter="" >
                    </div>
                    <label class="layui-form-label label-required-next">权限验证：</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="radio" name="auth_open" value="1" title="是" lay-filter=""  checked>
                        <input type="radio" name="auth_open" value="2" title="否" lay-filter="" >
                        <p class="help-block">是否将该菜单加入权限验证！</p>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">地址：<!--<br><span class="nowrap color-desc">允许类型</span>--></label>
                    <div class="layui-input-block input-custom-width" style="">
                        <input type="text" name="name" value="" placeholder="请求地址" lay-verify="" lay-vertype="tips" lay-reqtext="请求地址" autocomplete="off" class="layui-input ">
                        <p class="help-block">格式例如：AuthRule/index（控制器名/方法名）</p>
                    </div>

                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">是否禁止：</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="radio" name="status" value="1" title="正常" lay-filter=""  checked>
                        <input type="radio" name="status" value="0" title="禁止" lay-filter="" >
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>

                    <label class="layui-form-label label-required-next">菜单排序：</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="number" name="sort"  value="0"   placeholder="排序" lay-verify="" lay-verType="tips" lay-reqText="排序"  autocomplete="off"  class="layui-input">
                        <p class="help-block">数字越大越靠前</p>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">其它参数：</label>
                    <div class="layui-input-block input-custom-width" style="">
                        <input type="text" name="param" value="" placeholder="" lay-verify="" autocomplete="off" class="layui-input ">
                        <p class="help-block">控制器地址请求带的其它参数</p>
                    </div>

                </div>


                <div class="layui-form-item layui-layout-admin " style="width: 100%">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0px;text-align: center;">
                            <button class="layui-btn" lay-submit="" lay-filter="add">{:__('Submit')}</button>
                            <button type="reset" class="layui-btn layui-btn-primary">{:__('Reset')}</button>
                        </div>
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>


<script>
    layui.use(['element', 'form', 'jquery','iconHhysFa','lucky'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var iconHhysFa = layui.iconHhysFa;
        var lucky=layui.lucky;

        //表单赋值
        var info = {:json_encode($info)};
        form.val("form",info);

        iconHhysFa.render({
            // 选择器，推荐使用input
            elem: '#iconPicker',
            type: 'awsonme',
            // fa 图标接口
            url: "__PLUG__/font-awesome/less/variables.less",
            // 是否开启搜索：true/false，默认true
            search: true,
            // 是否开启分页：true/false，默认true
            page: true,
            // 每页显示数量，默认12
            limit: 12,
            // 点击回调
            click: function (data) {
                //console.log(data);
            },
            // 渲染成功后的回调
            success: function (d) {
                //console.log(d);
            }
        });

        form.on('submit(add)', function (data) {
            lucky.FormSubmit("{:url('addAuth')}",data.field,true);
            return false;
        });
    })
</script>

{/block}

